<?php

/**
 * @author Cesar Augustus Silva <cesaraugustussilva@linuxmail.org>
 * @copyright Copyright (c) 2013, Cesar Augustus Silva
 * @license http://www.gnu.org/licenses/gpl.html GNU GPL v3.0
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <­http://www.gnu.org/licenses/>.
 */
if ($_REQUEST) {
    require_once(dirname(__FILE__) . '/../config/config.inc.php');

    ob_start();

    $id = $_REQUEST['id'];
    if ($_REQUEST['id_product']>0) {  
        $data = DbGet::products_proposals($id);
    } else {
        $data = DbGet::proposal($id);
    }

    if ($data) {
        if ($_REQUEST['id_product']>0) {
            DbSet::products_proposals(array('read' => 1), $id);
        } else {
            DbSet::proposals(array('read' => 1), $id);
        }
        $data->phone = Util::format_phone($data->phone);
    }

    echo json_encode($data);
    
}